#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    srand(time(nullptr));
    setWindowOpacity(0.5);
    QPixmap pixmap(":/fiynkkjrpog");

    QCursor cursor(pixmap);
    ui->pushButton_2->setCursor(cursor);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    ui->label->setText("邦迪也喜欢你！！！");
    float opcity=this->windowOpacity();
    if(opcity<=1)
        opcity+=0.1;
    this->setWindowOpacity(opcity);
}

void Widget::on_pushButton_2_clicked()
{
    int ww=this->geometry().width();
    int hh=this->geometry().height();

    int x=rand()%ww;
    int y=rand()%hh;
    ui->pushButton_2->move(x,y);
}
